﻿using SuperSocket.Facility.Protocol;
using System.Linq;

namespace JT808_win
{
    public class JT808Filter : BeginEndMarkReceiveFilter<JT808RequestInfo>
    {
        public JT808Filter() : base(new byte[] { JT808.Protocol.JT808Package.BeginFlag }, new byte[] { JT808.Protocol.JT808Package.EndFlag })
        {
            

        }
        protected override JT808RequestInfo ProcessMatchedRequest(byte[] readBuffer, int offset, int length)
        {
            //通过解析到的数据来构造请求实例，并返回
            var totalBuffer = readBuffer.Skip(offset).Take(length).ToArray();
            var str = System.Text.Encoding.UTF8.GetString(totalBuffer);
            var info = new JT808RequestInfo(totalBuffer);
            return info;
            //return new StringRequestInfo("", body, null);
            //throw new NotImplementedException();
        }
    }
}
